<template>
	<view class="content first-font">
		<u-tabs :list="list" :is-scroll="false" :current="current" @change="change"></u-tabs>
<!-- 		<view v-for="(pageitem,index) in consultinfo.dispensings[current]">
			<view>
				{{pageitem}}
			</view>
		</view> -->
		<view class="tipbox">
			普通药品处方
		</view>
		<view class="prescriptionbox">
			<view class="title">
				<u-row>
					<u-col span="12">
						<u-row class="titletext">
							第二人民医院
						</u-row>
						<u-row class="titletext">
							处方笺
						</u-row>
					</u-col>
				</u-row>
			</view>
			<u-row class="info">
				<u-col span="3">
					姓名&nbsp;{{userbaseinfo.personName}}
				</u-col>
				<u-col span="2">
					性别&nbsp;{{userbaseinfo.personGenderName}}
				</u-col>
				<u-col span="3">
					年龄&nbsp;{{userbaseinfo.personAge}}岁
				</u-col>
				<u-col span="4">
					日期&nbsp;{{userbaseinfo.consultCreateTime}}
				</u-col>
			</u-row>
			<u-row class="info">
				<u-col span="7">
					身份证号&nbsp;{{userbaseinfo.personCardId}}
				</u-col>
				<u-col span="5">
					手机号&nbsp;{{userbaseinfo.personPhoneNo}}
				</u-col>
			</u-row>
			<view class="separate"></view>
			<view class="contentbox">
				<u-row class="line1">
					<u-col>
					RP
					</u-col>
				</u-row>
				<view v-for="drugitem in consultinfo[current].drugs">
<!-- 					{{pageitem}} -->
						<u-row class="line2">
							<u-col span="9">
								<u-row>
									{{drugitem.tradeName}}
								</u-row>
								<u-row class="second-font">
									<u-col span="6">
										用法：{{drugitem.specification}}
									</u-col>
									<u-col span="4">
										{{drugitem.frequencyName}}
									</u-col>
									<u-col span="2">
										{{drugitem.usageName}}
									</u-col>
								</u-row>
							</u-col>
							<u-col span="3" class="line2-1">
								{{drugitem.quantity}}盒
							</u-col>
						</u-row>						
				</view>
				<u-row>
					<u-col offset="9" span="3">
						药费：0.01元
					</u-col>
				</u-row>
				<u-row>
					处方医师：
				</u-row>
				<u-row>
					审核医师：
				</u-row>
				<u-row>
					发药医师：
				</u-row>
				<u-row>
					<u-col>
						<view class="third-font tips">
							*药师温馨提示：请遵医嘱服药！处方当日有效
						</view>
					</u-col>
				</u-row>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				pageindex:0,
				consultinfo:[],
				userbaseinfo:{},
				list:[],
				current: 0
			}
		},
		methods:{
			change(pageindex) {
				this.current = pageindex;
			}
		},
		onLoad:function (option){
			var test=[];
			this.userbaseinfo={
				personName:getApp().globalData.patientlist[option.id].personName,
				personGenderName:getApp().globalData.patientlist[option.id].personGenderName,
				personAge:getApp().globalData.patientlist[option.id].personAge,
				consultCreateTime:getApp().globalData.patientlist[option.id].consultCreateTime,
				personCardId:getApp().globalData.patientlist[option.id].personCardId,
				personPhoneNo:getApp().globalData.patientlist[option.id].personPhoneNo
			}
			uni.request({
				url: getApp().globalData.hostip+'Demo/preInfo/findByConsult?id='+getApp().globalData.patientlist[option.id].consultId, 
				data: {
				},
				fail:(fa) =>{
					console.log(fa)
				},
				success: (res) => {
					res.data.forEach(function(temp){
						test.push({
							prescriptionId:temp.prescriptionId,
							drugs:[]
						})						
					})
					this.consultinfo=test;
					this.consultinfo.forEach(function(temp2){
						uni.request({
							url: getApp().globalData.hostip+'Demo/preInfo/getById?id='+temp2.prescriptionId,
							data: {
							},
							fail:(fa) =>{
								console.log(fa)
							},
							success: (res) => {
								res.data.drugs.forEach(function(temp3){
									temp2.drugs.push({
										usageName:temp3.usageName,
										tradeName:temp3.tradeName,
										specification:temp3.specification,
										packUnit:temp3.packUnit,
										frequencyName:temp3.frequencyName,
										takeDays:temp3.takeDays,
										quantity:temp3.quantity,
										remark:temp3.remark
									})
								})
							}
						})
					})
					for(var i=1;i<=this.consultinfo.length;i++){
						this.list.push({
							name:'处方'+i
						})
					}
				}
			});
			// this.$forceUpdate()
		}
	}
</script>

<style scoped>
	.tipbox{
		position: absolute;
		/* margin-top: 30rpx; */
		border: 2px solid;
		margin-left: 550rpx;
		width: 100rpx;
		text-align: center;
		margin-top: 30rpx;
	}
	.prescriptionbox{
		margin-top: 44rpx;
		margin-left: 20rpx;
		margin-right: 20rpx;
	}
	.title{
		text-align: center;
		font-size: 36rpx;
		font-weight: bold;
		margin-bottom: 44rpx;
	}
	.titletext{
		text-align: center;
	}
	.info{
		padding: 28rpx;
	}
	.separate{
		margin-top: 100rpx;
	}
/* 	.u-row{
		margin-left: 40rpx;
		margin-right: 40rpx;
	} */
	.line1{
		font-size: 36rpx;
		font-weight: bold;
	}
	.contentbox{
		margin-top: 44rpx;
	}
	.line2{
		padding: 20rpx;
	}
	.tips{
		text-align: center;
	}
</style>
